/**
 * 
 */
package ch.baeni.jee.service;

import javax.ejb.Stateless;
import javax.enterprise.event.Event;
import javax.inject.Inject;
import javax.persistence.EntityManager;

import ch.baeni.jee.model.Link;

/**
 * Service-Klasse fuer alle Aenderungen an Links
 * 
 * @author Benjamin
 * 
 */
@Stateless
public class LinkService {

	@Inject
	EntityManager em;

	@Inject
	private Event<Link> linkEventSrc;

	/**
	 * Link speichern
	 * @param link Zu speichernder Link
	 */
	public void saveLink(Link link) {
		em.persist(em.merge(link));
		linkEventSrc.fire(link);
	}

	/**
	 * Link loeschen
	 * @param link Zu loeschender Link
	 */
	public void deleteLink(Link link) {
		em.remove(em.merge(link));
	}

}
